$('#btn').click(function (e) {
      e = e || window.event 
      e.preventDefault()
      let uname = $('#uname').val()
      let upass = $('#upass').val()
      // console.log(uname,upass);
      let uid = createId()
        if(!uname || !upass) {
          alert("请输入用户名或密码")
          return
        }
      $.ajax({
        url:'/register',
        dataType:'text',
        type:'post',
        data:{uname,upass,uid},
        success: function (response) {
            let res = JSON.parse(response)
            if(res.code === 1 ) {
              window.location.href = './login.html'
            }else {
              alert('注册失败')
            }
        }
      })
})



let createId = () => {
  let str = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'
  let id = ''
  for(let i = 0 ; i < 16 ; i ++ ) {
    let index = Math.floor(Math.random()*63)
    id += str[index]
  }
  return id 
}